﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

#include"RBTree.h"
#include"Mymap.h"
#include"Myset.h"

void test_set()
{
	study::set<int> s;
	s.insert(4);
	s.insert(1);
	s.insert(2);
	s.insert(3);
	s.insert(2);
	s.insert(0);
	s.insert(10);
	s.insert(5);

	study::set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		cout << *it << endl;
		it++;
	}
	cout << endl;

	it = s.begin();
	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test_map()
{
	study::map<string, string> dict;
	dict.insert(make_pair("sort", ""));
	dict.insert(make_pair("sort", "xx"));
	dict.insert(make_pair("left", ""));
	dict.insert(make_pair("right", "yy"));

	//study::map<string, string>::iterator it1 = dict.begin();
	//while (it1 != dict.end())
	//{
	//	// key޸
	//	//it->first += 'x';
	//	//it1->second += 'y';

	//	cout << it1->first << ":" << it1->second << endl;
	//	++it1;
	//}
	//cout << endl;

	string arr[] = { "哈密瓜", "香蕉","火龙果", "香蕉", "香蕉", "火龙果"};
	study::map<string, int> countMap;
	for (auto& e : arr)
	{
		countMap[e]++;
	}

	for (auto& kv : countMap)
	{
		cout << kv.first << ":" << kv.second << endl;
	}
	cout << endl;
}


int main()
{
	test_set();
	test_map();
	return 0;
}